Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Changing field attributes in a temp-table buffer

You can change certain field attributes in a dynamic temp-table after you have prepared it, including the label, format, help, and column-label. You do this by using the DEFAULT-BUFFER-HANDLE and setting one or more field attributes on a buffer-field. This is only possible with dynamic temp-tables.

For example, adding this code to the previous example changes the label and format of the CustNum field:

DEFINE VARIABLE hTT      AS HANDLE     NO-UNDO. 
DEFINE VARIABLE hCustNum AS HANDLE     NO-UNDO. 
DEFINE VARIABLE hTTB     AS HANDLE     NO-UNDO. 
CREATE TEMP-TABLE hTT. 
hTT:CREATE-LIKE("Customer","Name"). 
hTT:ADD-FIELDS-FROM("SalesRep","MonthQuota"). 
hTT:ADD-LIKE-FIELD("Area", "SalesRep.Region"). 
hTT:ADD-NEW-FIELD("Sequence", "INTEGER",0,"9999",1000). 
hTT:ADD-LIKE-INDEX("CustNum","CustNum","Customer"). 
hTT:ADD-NEW-INDEX("SeqIndex", YES). 
hTT:ADD-INDEX-FIELD("SeqIndex", "Sequence"). 
hTT:TEMP-TABLE-PREPARE("CustSequence"). 
CREATE BUFFER hTTB FOR TABLE hTT:DEFAULT-BUFFER-HANDLE  
    BUFFER-NAME "CustSeq2". 
ASSIGN hCustNum = hTT:DEFAULT-BUFFER-HANDLE:BUFFER-FIELD("CustNum") 
       hCustNum:LABEL = "Test" 
       hCustNum:FORMAT = "999999". 
MESSAGE "Label: " hCustNum:LABEL  
         "Format: " hCustNum:FORMAT VIEW-AS ALERT-BOX. 

The MESSAGE shown in Figure 20–1 confirms that the field format and label have changed.

Figure 20–1: Changed field attributes message

If you look at the CustNum label and format through the second dynamic buffer, the CustSeq2 buffer, you see that the format and label of the second buffer have the same value as in the default buffer even though the field in the default buffer was only changed after the second buffer was created.

To illustrate an important point about multiple temp-table buffers:

  1. Change the message statement to display the attributes through the second buffer:
  2. ASSIGN hCustNum = hTT:DEFAULT-BUFFER-HANDLE:BUFFER-FIELD("CustNum") 
           hCustNum:LABEL = "Test" 
           hCustNum:FORMAT = "999999". 
    MESSAGE "Label: " hTTB:BUFFER-FIELD("CustNum"):LABEL SKIP 
           "Format: " hTTB:BUFFER-FIELD("CustNum"):FORMAT VIEW-AS ALERT-BOX. 
    

    The label and format are changed, even as seen through the second buffer:

  3. Add a line of code that sets the label of the CustNum field in the second buffer:
  4. hTTB:BUFFER-FIELD("CustNum"):LABEL = "Okay". 
    ASSIGN hCustNum = hTT:DEFAULT-BUFFER-HANDLE:BUFFER-FIELD("CustNum") 
           hCustNum:LABEL = "Test" 
           hCustNum:FORMAT = "999999". 
    MESSAGE "Label: " hTTB:BUFFER-FIELD("CustNum"):LABEL SKIP 
           "Format: " hTTB:BUFFER-FIELD("CustNum"):FORMAT VIEW-AS ALERT-BOX. 
    

    None of the changes made to the default buffer are seen in that buffer:

    So the rule is that any changes you make to fields through the default buffer are also seen in any additional dynamic buffers for the temp-table, if no other changes have been made through the other buffer. Otherwise, the alternate buffer’s field attributes are initialized to the state of the fields at the time the alternate buffer is created. In that case, any changes made to fields through the alternate buffer are not seen in the default buffer, and any other changes made to the default buffer after that remain separate from the alternate buffer.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095